<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>练习4</title>
</head>
<body>
    <div id="app">

    </div>

    <!-- 引入react 核心库 -->
    <script type="text/javascript" src="./js/react.development.js"></script>
    <!-- 引入react-dom 用于支持react操作dom -->
    <script type="text/javascript" src="./js/react-dom.development.js"></script>
    <!-- 引入babel 用于讲jsx转成js -->
    <script type="text/javascript" src="./js/babel.min.js"></script>

    <!-- 组 件 -->
    <script type="text/babel">
        class Demo extends React.Component{
            constructor(props) {
                super(props);
                this.state = {msg:'一则消息',count:1}
                this.change = this.change.bind(this)
            }
            change(){
                const count = this.state.count;
                this.setState({count:count+1})
            }
            render() {
                return (
                    <div>
                        <h1 onClick={this.change}>{this.state.msg},{this.state.count}</h1>
                    </div>
                );
            }
        }
        ReactDOM.render(<Demo/>,document.getElementById('app'))
    </script>
</body>

</html>